<!--
 * @Author Malred · Wang
 * @Date 2025-06-17 13:29:58
 * @Description 
 * @Path src/components/base/operation/select.vue
 -->
<!-- operation-select.vue -->
<template>
  <el-form-item :label="label">
    <el-select v-model="selectedValue" placeholder="请选择">
      <el-option
          v-for="option in options"
          :key="option.value"
          :label="option.label"
          :value="option.value"
      />
    </el-select>
  </el-form-item>
</template>

<script setup>
import { defineProps, defineEmits, ref } from 'vue';

const props = defineProps({
  label: String,
  value: [String, Number],
  options: {
    type: Array,
    default: () => []
  }
});

const emit = defineEmits(['update:value']);

const selectedValue = ref(props.value);

// 监听值变化并通知父组件
watch(selectedValue, (newVal) => {
  emit('update:value', newVal);
});
</script>
